<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of CategoryToNameTransformer
 *
 * @author bien.tran
 */
namespace Blog\BlogBundle\Form\DataTransformer;

use Blog\BlogBundle\Entity\NewsCategories;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
class CategoryToNameTransformer implements DataTransformerInterface  {
    //put your code here
    //private $art;
    public function __construct() {
        //$this->art = $art;
    }
    public function reverseTransform($title) {
        //$title = $this->art->getRepository('BlogBundle:NewsArticles')->findOneBy(array('id' => 1));
        $title->setTitle($title->getTitle() . ' plus string here');
        return $title;
    }
    public function transform($title) {
        if($title === null)
            return "";
        //date_format($date, 'Y-m-d H:i:s');
        $title->setTitle('****--- ' . $title->getTitle() . ' ---****');
        return $title;
    }
}

?>
